{% extends "../layouts/base.twig" %}

{% block title %}主页{% endblock %}

{% block styles %}
{% endblock %}

{% block body %}
    <div class="container-fluid">
        <form method="post" action="" id="hand_form" onsubmit="return false;">
            <div class="form-group">
                <label for="original">原数据</label>
                <input type="text" class="form-control" name="original" id="original" placeholder="原数据">
                <span id="helpBlock" class="help-block"></span>
            </div>
            <div class="form-group">
                <label class="radio-inline">
                    <input type="radio" name="change_type" id="change_type" value="0" checked="checked"> md5加密
                </label>
                <label class="radio-inline">
                    <input type="radio" name="change_type" id="change_type" value="1"> md5解密
                </label>
            </div>
            <button type="submit" class="btn btn-default" onclick="hand()">提交</button>
        </form>
    </div>
{% endblock %}

{% block scripts %}
    <script>
        function hand(){
            $.ajax({
                url:'/encrypt/md5',
                type:'POST',
                cache:false,
                data:new FormData($('#hand_form')[0]),
                processData:false,
                contentType:false
            }).done(function(res){
                if(res.status == 1){
                    $('#helpBlock').html("加密成功.结果为:"+res.data);
                }
            }).fail(function(res){
                console.log(res)
            })
        }
    </script>
{% endblock %}